package com.jeejam.product.dubbo;

import com.alibaba.dubbo.config.annotation.Service;
import com.jeejam.product.pojo.ProductAttribute;
import com.jeejam.product.sdk.api.IProductAttributeService;
import com.jeejam.product.sdk.dto.ProductAttributeDto;
import com.jeejam.product.service.ProductAttributeService;
import com.jeejam.util.ShopBeanBuildUtil;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by JACKEY on 2016/3/26.
 */
@Service(version = "1.0.0")
public class ProductAttributeDubboService implements IProductAttributeService {

    @Resource
    private ProductAttributeService productAttributeService;

    @Override
    public ProductAttributeDto get(int productId, int attributeId) {
        return ShopBeanBuildUtil.slmCopyBean(productAttributeService.get(productId, attributeId), ProductAttributeDto.class);
    }

    @Override
    public void deleteByProductId(int productId) {
        productAttributeService.deleteByProductId(productId);
    }

    @Override
    public List<ProductAttributeDto> findByProductId(int productId) {
        return ShopBeanBuildUtil.slmCopyBeanList(productAttributeService.findByProductId(productId), ProductAttributeDto.class);
    }

    @Override
    public void save(ProductAttributeDto productAttributeDto) {
        productAttributeService.save(ShopBeanBuildUtil.slmCopyBean(productAttributeDto, ProductAttribute.class));
    }

    @Override
    public void update(ProductAttributeDto productAttributeDto) {
        productAttributeService.update(ShopBeanBuildUtil.slmCopyBean(productAttributeDto, ProductAttribute.class));
    }
}
